//
//  YKClientOrderListViewController.m
//  YunKang
//
//  Created by leoking870 on 2017/10/2.
//  Copyright © 2017年 leoking870. All rights reserved.
//

#import "YKClientOrderListViewController.h"
#import "YKClientListHeaderView.h"
#import "YKClientOrderItem.h"
#import "YKClientOrderDetailViewController.h"
#import "YKClientOrderV2Item.h"
@interface YKClientOrderListViewController ()

@end

@implementation YKClientOrderListViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
//     YKClientListHeaderView* headerView = [[YKClientListHeaderView alloc]initWithTitles:@[@"订单单号",@"企业名称",@"订单状态",@"订单日期"]
//                                                                                weights:@[@1,@2,@1,@1]
//                                                                               spaceing:0
//                                                                                leading:5
//                                                                               trailing:5];
//
//    if (self.istatus.length > 0) {
//        headerView = [[YKClientListHeaderView alloc]initWithTitles:@[@"订单单号",@"企业名称",@"订单日期"]
//                                                          weights:@[@1,@2,@1]
//                                                         spaceing:0
//                                                          leading:5
//                                                         trailing:5];
//    }
//    [self.view addSubview:headerView];
//    headerView.textFont = [UIFont systemFontOfSize:16];
//    [headerView mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.leading.trailing.equalTo(self.view);
//        make.top.equalTo(self.view.mas_top);
//    }];
    
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
    
    [self.tableView mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.leading.bottom.trailing.equalTo(self.view);
//        make.top.equalTo(headerView.mas_bottom);
        make.top.equalTo(self.view.mas_top);
    }];
    self.tableView.tableFooterView = [UIView new];
    
    self.dataSource.totalPageKey = @"page.totalpage";
    self.dataSource.currentPageKey = @"curpage";
    [self startLoadData];
}
- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    if (self.dataSource.manager.sections.count > 0) {
        [self startLoadDataSilently];
    }
}

- (NSDictionary *)pageViewControllerParameters {
    return @{
             kTFPageViewControllerItemClass: [YKClientOrderV2Item class],
             kTFPageViewControllerModelClass:[YKClientOrderModel class],
             kTFPageViewControllerRequestURL:@"customerOrder/customerOrderList.htm",
             kTFPageViewControllerDataKeyPath:@"list",
             kTFPageViewControllerRequestParameter:@{@"c_name":self.c_name,@"istatus":self.istatus}
             };
}
-(void)customizeItem:(YKClientOrderItem *)item {
    item.hideSeparator = NO;
    item.separatorSunk = NO;
    item.istatus = self.istatus;
//    item.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    item.selectionHandler = ^(__kindof YKClientOrderItem *item, NSIndexPath *indexPath) {
        YKClientOrderDetailViewController *vc = [[YKClientOrderDetailViewController alloc]init];
        vc.ID = item.model.ID;
        vc.status = item.model.ISTATUS;
        [self.navigationController pushViewController:vc animated:YES];
    };
}
@end
